﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core;
using Cofe.Core.Validater;
using ExifLib;

namespace Cofe.Media
{
    [PropertyId(500, 509)]
    public enum CofeMediaProperties : int
    {
        [PropertyType(typeof(byte[]))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)] //DBCachable in MediaInfo
        FullThumbnail = 500,

        /// <summary>
        /// Parse full thumbnail to return a thumbnail that match the width and height.
        /// </summary>
        [Action(ActionType.Async, typeof(BitmapContainer), "Width", "Height")]
        [WebResource(MediaType.Jpeg, true, WebCacheMethod.LastModified, "Width", "Height")]
        [Alias("Thumbnail")]
        GetThumbnailAsync,

        [PropertyType(0, typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)] //DBCachable in ImageInfo        
        [ExifTag(ExifTags.PixelXDimension)]
        [WebMetadata(true)]
        [Alias(false)]
        Width,

        [PropertyType(0, typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)] //DBCachable in ImageInfo
        [ExifTag(ExifTags.PixelYDimension)]
        [WebMetadata(true)]
        [Alias(false)]
        Height,

        
    }

    [PropertyId(510, 539)]
    public enum ExifProperties : int
    {
        //From Exifs
        [PropertyType(0, typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)] 
        [ExifTag(ExifTags.XResolution)]
        [Alias(false)]
        XResolution =  510,

        [PropertyType(0, typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)] 
        [ExifTag(ExifTags.YResolution)]        
        [Alias(false)]
        YResolution,
       
        [PropertyType("", typeof(string))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.Model)]
        [WebMetadata(false)]
        [Alias("Model")]
        CameraModel,

        [PropertyType("", typeof(string))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.Make)]
        [WebMetadata(false)]
        [Alias("Maker")]
        CameraMaker,

        [PropertyType(1, typeof(Int16))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.Orientation)]
        [WebMetadata(true)]
        [Alias(false)]
        Orientation,
       
        [PropertyType("", typeof(Int16))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [ExifTag(ExifTags.ResolutionUnit)]
        [Alias(false)]
        ResolutionUnit,

        [PropertyType(PropertyTypeAttribute.DateTimeDefaultEnum.Min)]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.DateTime)]
        [WebMetadata(false)]
        [Alias("CaptureTime")]
        DateTime,

        [PropertyType(PropertyTypeAttribute.DateTimeDefaultEnum.Min)]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [ExifTag(ExifTags.DateTimeOriginal)]
        DateTimeOriginal,

        [PropertyType(PropertyTypeAttribute.DateTimeDefaultEnum.Min)]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [ExifTag(ExifTags.DateTimeDigitized)]
        DateTimeDigitized,

        [PropertyType("", typeof(float))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.ApertureValue)]
        [WebMetadata(false)]
        [Alias(false)]
        Aperture,

        [PropertyType("", typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.FNumber)]
        [WebMetadata(false)]
        [Alias(false)]
        FNumber,
        
        [PropertyType("", typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.ExposureTime)]
        [WebMetadata(false)]
        [Alias("ShutterSpeed")]        
        ExposureTime,

        [PropertyType("", typeof(Int16))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [ExifTag(ExifTags.ExposureProgram)]
        [Alias(false)]        
        ExposureProgram,
        
        [PropertyType("", typeof(Int16))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.ISOSpeedRatings)]
        [WebMetadata(false)]
        [Alias(false)]
        ISO,

        [PropertyType("", typeof(Int32))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.FocalLength)]
        [WebMetadata(false)]
        [Alias(false)]
        FocalLength,

        [PropertyType(false, typeof(Int16))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachableORM)]
        [ExifTag(ExifTags.Flash)]
        [WebMetadata(false)]
        [Alias(false)]
        Flash,

        /// <summary>
        /// 12 34' 56.78" N
        /// </summary>
        [PropertyType(0.0d, typeof(double))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [WebMetadata(true)]
        [Alias(false)]
        GPSLatitude,

        /// <summary>
        /// 12 34' 56.78" W
        /// </summary>
        [PropertyType(0.0d, typeof(double))]
        [Cachable(PropertyCacheOptions.Cachable, DatabaseCacheOptions.CachablePropertyPairs)]
        [WebMetadata(true)]
        [Alias(false)]
        GPSLongitude

    }
}
